﻿
Imports xmlctrl

Public Class iframeJumpKeeper
    Public Shared Sub invoke(ByVal page As xhtmlpage)
        assert(Not page Is Nothing, "page is nothing.")
        Dim isIEUserAgentAction As String = Nothing
        isIEUserAgent.invoke(page.inlineScript(), isIEUserAgentAction)
        var.invoke(page.inlineScript(), "wndUnloadMsg" _
                   , "'please cancel this action if you do not want to leave the page.'")
        Dim oneparaAlertAction As String = Nothing
        oneparaAlert.invoke(page.inlineScript(), windowUnload.parameterName, "wndUnloadMsg", oneparaAlertAction)
        oneparaAlertAction += ";"
        Dim ieAction As String = Nothing
        ieAction = "var location=''; var navigate='';"
        Dim windowUnloadAction As String = Nothing
        windowUnload.invoke(oneparaAlertAction, windowUnloadAction)
        Dim ifelseAction As String = Nothing
        ifelse.invoke(isIEUserAgentAction, ieAction, windowUnloadAction, ifelseAction)
        page.inlineScript().addscript(network.http.contentType.textjavascript, "iframeJumpKeeper", ifelseAction)
    End Sub
End Class
